C C -C Programming /C Multiple Choice Questions Sample Test,Sample questions

Question:
Comment on the following expression? c = (n) ? a : b; can be rewritten as

1.if (!n)c = b; else c = a

2.if (n <= 0)c = b; else c = a

3. if (n > 0)c = a; else c = b;

4.All of the mentioned


Question:
Comment on the output of this C code?

void main()
{
int k = 8;
int m = 7;
int z = k < m ? k = m : m++;
printf("%d", z);
}

1.Run time error

2.7

3.8

4.Depends on compiler


Question:
For initialization a = 2, c = 1 the value of a and c after this code will be c = (c) ? a = 0 : 2;

1.a = 0, c = 0;

2.a = 2, c = 2;

3.a = 2, c = 2

4. a = 1, c = 2;


Question:
The code snippet below produces

void main()
{
1 < 2 ? return 1 : return 2;
}

1.returns 1

2.returns 2

3.varies

4.Compile time error


Question:
The output of the code below is

void main()
{
int k = 8;
int m = 7;
k < m ? k = k + 1 : m = m + 1;
printf("%d", k);
}

1.Compile time error

2.9

3.8

4.Run time error


Question:
The output of the code below is

void main()
{
int k = 8;
int m = 7;
k < m ? k++ : m = k;
printf("%d", k);
}

1.7

2.8

3.Compile time error

4.Run time error


Question:
Value of c after the following expression (initializations a = 1, b = 2, c = 1): c += (-c) ? a : b;

1.syntax error

2.c = 1

3.c = 2

4.c = 3


Question:
What is the output of this C code?

int main()
{
int a = 2;
int b = 0;
int y = (b == 0) ? a :(a > b) ? (b = 1): a;
printf("%d
", y);
}

1.Compile time error

2.1

3.2

4.Undefined behaviour


Question:
What is the output of this C code?

int main()
{
int x = 1;
int y = x == 1 ? getchar(): 2;
printf("%d
", y);
}

1.Compile time error

2.Whatever character getchar function returns

3.Ascii value of character getchar function returns

4.2


Question:
What is the output of this C code?

int main()
{
int x = 1;
short int i = 2;
float f = 3;
if (sizeof((x == 2) ? f : i) == sizeof(float))
printf("float
");
else if (sizeof((x == 2) ? f : i) == sizeof(short int))
printf("short int
");
}

1.float

2.short int

3.Undefined behaviour

4.Compile time error


Question:
What is the output of this C code?

int main()
{
int x = 2, y = 0;
int z = (y++) ? y == 1 && x : 0;
printf("%d
", z);
return 0;
}

1.0

2.1

3.Undefined behavior

4.Compile time error


Question:
What is the output of this C code?

int main()
{
int y = 1, x = 0;
int l = (y++, x++) ? y : x;
printf("%d
", l);
}

1.1

2.2

3.Compile time error

4.Undefined behaviour


Question:
What is the output of this C code?

void main()
{
int k = 8;
int m = 7;
int z = k < m ? k++ : m++;
printf("%d", z);
}

1.7

2.8

3.Run time error

4.None of the mentioned.


Question:
What will be the data type of the expression (a < 50) ? var1 : var2; provided a = int, var1 = double, var2 = float

1.float

2.int

3.double

4.Cannot be determined


Question:
Which expression has to be present in the following? exp1 ? exp2 : exp3;

1.exp1

2.exp2

3.exp3

4.All of the mentioned


More MCQS

  1. C++ Programming MCQS Set-1
  2. C++ Multiple Choice Questions Set-1
  3. C++ Multiple Choice Questions Set-2
  4. C++ Programming MCQS Set-2
  5. C++ Programming MCQS Set-3
  6. C++ Programming MCQS Set-4
  7. C++ (CPP) MCQ Question with Answer
  8. Advanced c++ multiple choice question(MCQS)
  9. OOPS Quiz Questions and Answers(MCQS)
  10. C Programming - MCQ Questions Set 1
  11. C Programming - MCQ Questions Set 2
  12. C Programming - MCQ Questions Set 3
  13. C Programming - MCQ Questions Set 4
  14. C Programming - MCQ Questions Set 5
  15. C++ programming language MCQ Questions Set 1
  16. C++ programming language MCQ Questions Set 2
  17. C++ programming language MCQ Questions Set 3
  18. C++ programming language MCQ Questions Set 4
  19. C++ programming language MCQ Questions Set 5
  20. C++ Programming -Constructors and Destructors
  21. C++ Programming -OOPS Concepts
  22. C++ Programming - References
  23. C++ Programming - Functions
  24. C MCQS:-The ABC of C
  25. C MCQS Interview Questions
  26. C++ Questions and Answers OOPs Basic Concepts
  27. C++ Questions and Answers Returning Objects
  28. C Programming MCQ Part 1
  29. C Programming MCQ
  30. Computer Science & Engineering C Multiple Choice Questions set 1
  31. Computer Science & Engineering C Multiple Choice Questions set 2
  32. C Multiple Choice Questions C Functions Set 1
  33. C Multiple Choice Questions C Functions Set 2
  34. C Multiple Choice Questions C Operators
  35. C Multiple Choice Questions & AnswersConditional Expressions
  36. C Multiple Choice Questions & Answers Data Types
  37. C Multiple Choice Questions & Answers File Access
  38. Computer Science & Engineering Cloud Computing MCQs Part 1
  39. CPP Programming MCQ Set 1
  40. CPP Programming MCQ Set 2
Search
Olete Team
Online Exam TestTop Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on Online Exam Testwebsite is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!